package Text_002;

import java.util.Scanner;

public class PriceCode {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入机票原价：");
		double  ticketPrice = scanner.nextDouble();
		System.out.println("请输入月份：");
		int month = scanner.nextInt();
		//定义 经济舱为1，头等舱为0；
		System.out.println("请输入买的舱型(经济舱 ， 头等舱)：");
		String Class = scanner.next();
		if(month>=5&&month<=10) {
			if(Class.equals("头等舱")==true) {
				ticketPrice = ticketPrice*0.9;
			}else if(Class.equals("经济舱")==true) {
				ticketPrice = ticketPrice*0.85;
			}
			
		}else if((month>0&&month<5)||(month>=11&&month<=12)) {
			if(Class.equals("头等舱") ) {
				ticketPrice = ticketPrice*0.7;
			}else if(Class.equals("经济舱")) {
				ticketPrice = ticketPrice*0.65;
			}
		}
		System.out.println("打折后机票价格为："+ticketPrice);
		System.out.println("=================");
		//优化
		/*
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入机票原价：");
		double  ticketPrice = scanner.nextDouble();
		System.out.println("请输入月份：");
		int month = scanner.nextInt();
		//定义 经济舱为1，头等舱为0；
		System.out.println("请输入买的舱型(1为经济舱 | 0为头等舱)：");
		int Class = scanner.nextInt();
		double  t = 0.0;
		if(month>=5&&month<=10) {
			  t = ticket(ticketPrice,Class,0.9,0.85);
			
		}else if((month>0&&month<5)||(month>=11&&month<=12)) {
			  t = ticket(ticketPrice,Class,0.7,0.65);
		}
		System.out.println("打折后机票价格为："+t);
		
	}
	public static double ticket(double ticketPrice,int Class,double v0,double v1 ) {
		if(Class==0) {
			ticketPrice = ticketPrice*v0;
		}else if(Class==1) {
			ticketPrice = ticketPrice*v1;
		}
		return ticketPrice ;
		*/

	}

}
